import Vue from 'vue'
import ElementUI from 'element-ui';
import 'element-ui/lib/theme-chalk/index.css';
import App from './App.vue'
import router from './router'
import VueRouter from 'vue-router'

import {
	postRequest
} from './utils/api.js'
import {
	putRequest
} from './utils/api.js'
import {
	getRequest
} from './utils/api.js'
import {
	deleteRequest
} from './utils/api.js'

import store from './store'

//引入echarts
import * as echarts from 'echarts'


Vue.use(ElementUI);

//注册为全局变量
Vue.prototype.$postRequest = postRequest;
Vue.prototype.$putRequest = putRequest;
Vue.prototype.$getRequest = getRequest;
Vue.prototype.$deleteRequest = deleteRequest;

Vue.config.productionTip = false

import {initMenu} from './utils/menus.js'
//#在路由前置守卫中调用
//路由前置守卫
router.beforeEach((to,from,next)=>{
//初始化我们的动态路由
initMenu(router,store);
next();
// console.log("-----to---------"+to.path);
// console.log("-----from---------"+from.path);
// if(to.path=="/"){
// next();
// }else{
// var admin = sessionStorage.getItem("admin")
// console.log("admin=====>"+admin);
// if(to.path=="/table" && admin!=null){
// next();
// }else{
// next("/");
// }
// }
});
//路由前置守卫
// router.beforeEach((to,from,next)=>{
// 	console.log("-----to---------"+to.path);
// 	console.log("-----from---------"+from.path);
// 	if(to.path=="/"){
// 		next();
// 	}else{
// 		var admin  = sessionStorage.getItem("admin")
// 		console.log("admin=====>"+admin);
// 		if(to.path=="/table" && admin!=null){
// 			next();
// 		}else{
// 			next("/");
// 		}
// 	}
// });

new Vue({
	store,
	router,
	render: h => h(App)
}).$mount('#app')